﻿using System;
using NTTDATA.BEENChina.ResultCertification.DataStore;

namespace NTTDATA.BEENChina.ResultCertification.Logic
{
    public class ActionMessage
    {
        private ActionMessage()
        {
        }

        private DataStore.IProcessLog processLog = new ProcessLogAccess();

        private static ActionMessage actionMessage;

        public static  ActionMessage GetInstance()
        {
            if (actionMessage == null)
                actionMessage = new ActionMessage();

            return actionMessage;
        }

        public   event EventHandler<ActionEvent> ProcessMessage;

        public void onProcessMessage(String message, EnumProcessModel model)
        {
            //save to db
            processLog.Write(message, model.ToString());

            if (ProcessMessage != null)
            {
                var e = new ActionEvent() { Message = message,Model =  model};

                //target event
                ProcessMessage(this, e);
            }
        }


    }

    public class ActionEvent : EventArgs
    {
        public String Message { get; set; }
        public EnumProcessModel Model { get; set; }
    }
}
